{layout name="layout" /}
<!-- Main content -->
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">权限编辑</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <form class="js-ajax-form ingeAjax" action="{:url('/home/Auth/auth_edit', 'id='.$id)}" method="post">
                        <div class="table_full">
                            <table class="table table-bordered" id="authrule-tree">
                                <tbody>
                                {$categorys}
                                </tbody>
                            </table>
                        </div>
                        <div class="form-actions">
                          <button class="btn btn-primary" type="submit">
                              <i class="fa fa-check bigger-110"></i> 保存
                          </button> &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset" onclick="history.go(-1);">
                                <i class="fa fa-undo bigger-110"></i> 返回
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
{include file="public/base" /} {include file="public/footer" /}
<script src="/static/plugins/treeTable/treeTable.js"></script>
<link rel="stylesheet" href="/static/plugins/treeTable/treeTable.css">
<script type="text/javascript">
    function checknode(obj) {
        var chk = $("input[type='checkbox']");
        var count = chk.length;
        var num = chk.index(obj);
        var level_top = level_bottom = chk.eq(num).attr('level');
        for (var i = num; i >= 0; i--) {
            var le = chk.eq(i).attr('level');
            if (le <level_top) {
                chk.eq(i).prop("checked", true);
                var level_top = level_top - 1;
            }
        }
        for (var j = num + 1; j < count; j++) {
            var le = chk.eq(j).attr('level');
            if (chk.eq(num).prop("checked")) {
                if (le > level_bottom){
                    chk.eq(j).prop("checked", true);
                }
                else if (le == level_bottom){
                    break;
                }
            } else {
                if (le >level_bottom){
                    chk.eq(j).prop("checked", false);
                }else if(le == level_bottom){
                    break;
                }
            }
        }
    }
    $(document).ready(function () {
        $("#authrule-tree").treeTable({
            indent: 20
        });
    });
</script>
</body>
</html>
